package design_mode.工厂模式;

import design_mode.工厂模式.运算方法.*;

public class OperationContext {
    // 策略工厂模式
    private AbstractOperation operation;

    public OperationContext(String operate) {
        switch (operate) {
            case "+":
                this.operation = new Add();
                break;
            case "-":
                this.operation = new Subtract();
                break;
            case "*":
                this.operation = new Multiplication();
                break;
            case "/":
                this.operation = new DivisionMethod();
                break;
        }
    }

    public double operationInterface(double numberA, double numberB) {
        return this.operation.getResult(numberA, numberB);

    }
}
